package com.zjsd.sqeybusiness.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.zjsd.sqeybusiness.domain.Dlpayment;
import com.zjsd.sqeybusiness.service.IDlpaymentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 代理账户变动明细Controller
 *
 * @author Zheng
 * @date 2022-05-10
 */
@RestController
@RequestMapping("/sqeybusiness/dlpayment")
public class DlpaymentController extends BaseController
{
    @Autowired
    private IDlpaymentService dlpaymentService;

    /**
     * 查询代理账户变动明细列表
     */
    //@PreAuthorize("@ss.hasPermi('sqeybusiness:dlpayment:list')")
    @GetMapping("/list")
    public TableDataInfo list(Dlpayment dlpayment)
    {
        startPage();
        List<Dlpayment> list = dlpaymentService.selectDlpaymentList(dlpayment);
        return getDataTable(list);
    }

    @PostMapping("/queryPayment")
    public TableDataInfo queryPayment(Dlpayment dlpayment)
    {
        startPage();
        List<Dlpayment> list = dlpaymentService.selectDlpaymentList(dlpayment);
        return getDataTable(list);
    }

    /**
     * 导出代理账户变动明细列表
     */
    //@PreAuthorize("@ss.hasPermi('sqeybusiness:dlpayment:export')")
    //@Log(title = "代理账户变动明细", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Dlpayment dlpayment)
    {
        List<Dlpayment> list = dlpaymentService.selectDlpaymentList(dlpayment);
        ExcelUtil<Dlpayment> util = new ExcelUtil<Dlpayment>(Dlpayment.class);
        return util.exportExcel(list, "dlpayment");
    }

    /**
     * 获取代理账户变动明细详细信息
     */
    //@PreAuthorize("@ss.hasPermi('sqeybusiness:dlpayment:query')")
    @GetMapping(value = "/{paymentid}")
    public AjaxResult getInfo(@PathVariable("paymentid") Long paymentid)
    {
        return AjaxResult.success(dlpaymentService.selectDlpaymentById(paymentid));
    }

    /**
     * 新增代理账户变动明细
     */
    //@PreAuthorize("@ss.hasPermi('sqeybusiness:dlpayment:add')")
    @Transactional
    //@Log(title = "代理账户变动明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Dlpayment dlpayment)
    {

        return toAjax(dlpaymentService.insertDlpayment(dlpayment));
    }

    /**
     * 修改代理账户变动明细
     */
    @Transactional
    //@PreAuthorize("@ss.hasPermi('sqeybusiness:dlpayment:edit')")
    //@Log(title = "代理账户变动明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Dlpayment dlpayment)
    {
        return toAjax(dlpaymentService.updateDlpayment(dlpayment));
    }

    /**
     * 删除代理账户变动明细
     */
    //@PreAuthorize("@ss.hasPermi('sqeybusiness:dlpayment:remove')")
    //@Log(title = "代理账户变动明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{paymentids}")
    public AjaxResult remove(@PathVariable Long[] paymentids)
    {
        return toAjax(dlpaymentService.deleteDlpaymentByIds(paymentids));
    }
}
